/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.ms.filecenter.application.action.auditlog;

import cn.hallele.ms.filecenter.application.bo.ApiLogBO;
import cn.hallele.ms.filecenter.application.das.ApiLogBDDas;
import cn.hallele.ms.infrastructure.auditlog.io.ApiLogIO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * hallele_ms_filecenter
 *
 * @author anle5
 * @since 2024/9/16 23:55
 */
@Slf4j
@Service
public class AuditLogApplicationService {
    @Autowired
    private ApiLogBDDas apiLogBDDas;

    /**
     * 消费消息
     *
     * @param apiLogIO api日志
     */
    public void applyApiLog(ApiLogIO apiLogIO) {
        apiLogBDDas.save(ApiLogBO.builder()
                .appName(apiLogIO.getAppName())
                .apiId(apiLogIO.getApiId())
                .tranceId(apiLogIO.getTranceId())
                .ip(apiLogIO.getIp())
                .clientInfo(apiLogIO.getClientInfo())
                .initiator(apiLogIO.getInitiator())
                .request(apiLogIO.getRequest())
                .response(apiLogIO.getResponse())
                .requestStartTime(apiLogIO.getStartTime())
                .requestEndTime(apiLogIO.getEndTime())
                .msgCode(apiLogIO.getMsgCode())
                .msgDesc(apiLogIO.getMsgDesc())
                .build());
    }
}